#define WAL_MART  '052399'
#define CIA_BRAS  '023838'
#define CARREFOUR '005009'

User Function PrazoPgto()
Local cCliente   := M->C5_CLIENTE
Local dDtEntrega := M->C5_DTENTRG
Local dDtPgto   := CToD("  /  /  ")

Do Case
	Case cCliente = WAL_MART
		dDtPgto := U_PrazoWalMart(dDtEntrega)
	Case cCliente = CIA_BRAS 
		dDtPgto := U_PrazoCiaBras(dDtEntrega)
	Case cCliente = CARREFOUR
		dDtPgto := U_PrazoCarrefour(dDtEntrega)	
EndCase

Return dDtPgto

User Function PrazoWalMart(dDtEntrega)
Local dDtPgto := CToD("  /  /  ")
Local nPrazo  := 60

dDtPgto := DaySum(dDtEntrega, nPrazo)
Return dDtPgto

User Function PrazoCiaBras(dDtEntrega)
Local dDtPgto := CToD("  /  /  ")
Local nPrazo  := 50
Local dDtPrzo := DaySum(dDtEntrega, nPrazo)
Local nDiaSem := Dow(dDtPrzo)

Do Case
	Case nDiaSem = 1
		dDtPgto := DaySum(dDtPrzo, 4)
	Case nDiaSem = 2
		dDtPgto := DaySum(dDtPrzo, 3)
	Case nDiaSem = 3
		dDtPgto := DaySum(dDtPrzo, 2)
	Case nDiaSem = 4
		dDtPgto := DaySum(dDtPrzo, 1)
	Case nDiaSem = 6
		dDtPgto := DaySum(dDtPrzo, 6)
	Case nDiaSem = 7
		dDtPgto := DaySum(dDtPrzo, 5)
	Otherwise
		dDtPgto := dDtPrzo
EndCase

Return dDtPgto

User Function PrazoCarrefour(dDtEntrega)
Local dDtPgto := CToD("  /  /  ")
Local nPrazo  := 44

dDtPgto := DaySum(dDtEntrega, nPrazo)
Return dDtPgto